<?php
header("content-type:text/html;charset=utf-8");
include "../public/config/config.php";
include "../public/include/funcs.php";
$link=conn($cfg_dbhost,$cfg_dbuser,$cfg_dbpwd,$cfg_dbname,$cfg_dbchar);
$id=$_GET['id'];
$arr_self=select($link, "user","id=$id");
$pid=$arr_self[0]['pid'];
if($pid==0){
	echo "<script>";
	echo "alert('他已经是顶级分销商了，没有上级。');";
	echo "window.location.href='index.php';";
	echo "</script>";
}else{
	$arr_all[]=$arr_self[0];
	while($pid>0){
		$arr=select($link, "user","id=$pid");
		$arr_all[]=$arr[0];
		$pid=$arr[0]['pid'];
	}
	$arr_all=array_reverse($arr_all);
}
echo "<pre>";
//print_r($arr_all);
echo "</pre>";
?>
<html>
	<head>
		<title><?php echo $arr_self[0]['tname']?>的上级层级结构</title>
		<link rel="stylesheet" type="text/css" href="../public/css/main.css"/>
	</head>
	<body>
<div class="cent w1000">
	<h3><?php echo $arr_self[0]['tname']?>的上级层级结构</h3>
	<div class="hei_50"></div>
<?php
foreach($arr_all as $k=>$v){
	if($k!=0){
?>
	<div class="name_jt">
		<span>--></span>
	</div>
<?php
	}
?>
	<div class="name_cell">
		<p><a href="index.php?pid=<?php echo $v['id']?>"><?php echo $v['tname'] ? $v['tname'] : $v['nickname']?></a></p>
		<p><?php echo $v['nickname']?></p>
	</div>
<?php
}
?>
</div>
	</body>
</html>